package com.zjcode.cdcer.controller;

import com.chinatechstar.component.commons.controller.BaseController;
import com.chinatechstar.component.commons.supports.PageData;
import com.zjcode.cdcer.model.basic.JsonObj;
import com.zjcode.cdcer.service.InitialDataReportingService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName:SystemInitController
 * @功能：初始数据上报
 * @author：wlei
 * @日期：2022/7/9-02:00
 **/
@RestController
@Slf4j
@RequestMapping("/v1/initialdatareporting/")
public class InitialDataReportingController extends BaseController {

    @Autowired
    private InitialDataReportingService initialDataReportingService;

    /**
     * 返回所有可以用于显示的表字段信息
     *
     * @return
     */
    @GetMapping("listAllTableColumn")
    public JsonObj listAllTableColumn() {
        PageData pageData = getPageData();
        JsonObj result = initialDataReportingService.listAllTableColumn();
        return result;
    }

    /**
     * 返回所有可以用于显示的表字段信息
     *
     * @return
     */
    @GetMapping("listAllTableColumn4Office")
    public JsonObj listAllTableColumn4Office() {
        PageData pageData = getPageData();
        JsonObj result = initialDataReportingService.listAllTableColumn4Office();
        return result;
    }

    @PostMapping("deleteById")
    public JsonObj deleteById() {
        PageData pageData = getPageData();
        return initialDataReportingService.deleteById(pageData);
    }

    @GetMapping("findById")
    public JsonObj findById() {
        PageData pageData = getPageData();
        String id = (String) pageData.get("id");
        return initialDataReportingService.findById(id);
    }

    @PostMapping("updateRecord")
    public JsonObj updateRecord() {
        PageData pageData = getPageData();
        return initialDataReportingService.updateRecord(pageData);
    }
}
